#!/bin/awk -f
# handles fig output; used by thsums
BEGIN{
}
$0~/input type/{
  if($0 ~ /mode 0/){
    n=1;
    tname=$1;
  }else{tnames=$1};
  next;
}
$0~/beta/{
  n++;
  next;
}
$0~/Checking/{
  for(i=4;i<=NF;i++){
    no++; ob[no]=$i;
  }
  next;
}
$0~/page/{next}
$3==""{next}
{
#  if(o[$3]==""){no++;ob[no]=$3}
  o[$3]++;
  s[n,$3]+=$1;
}
END{
  if(tnames){print "TILINGS from "tnames};
  printf " #";
  for(j=1;j<=no;j++){printf("%4s ",ob[j])}; print "";
  for(i=1;i<=n;i++){
    printf("%2i",i);
    for(j=1;j<=no;j++){
      x=0; if(s[i,ob[j]]>0){x=s[i,ob[j]]};
      printf("%5i",x);
    }
    print "  "tname;
  }
}
